<%--
  Created by IntelliJ IDEA.
  User: admin
  Date: 2018/8/27
  Time: 13:37
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/WEB-INF/jsp/component/common.jsp" %>
<html>
<head>
    <meta charset="UTF-8">
    <title>详细内容</title>
    <link rel="stylesheet" href="${frames}/css/lib/bootstrap.min.css" type="text/css">
    <link rel="stylesheet" href="${newframe}/css/base/base.css" type="text/css">
    <%--<link rel="stylesheet" href="${newframe}/css/common.css" type="text/css">--%>
    <link rel="stylesheet" href="${newframe}/css/select2.min.css" type="text/css">
    <link rel="stylesheet" href="${assets}/css/views/department/addDepartment.css">
    <!--[if IE 8]>
    <meta http-equiv="X-UA-Compatible"content="IE=EmulateIE7">
    <![endif]-->
    <%@ include file="/WEB-INF/jsp/component/commonBottom.jsp" %>
    <script src="${assets}/bootstrapValidator/js/bootstrapValidator.js"></script>
    <script src="${assets}/bootstrapValidator/js/language/zh_CN.js"></script>
    <script src="${newframe}/js/select2.full.zh.js"></script>

</head>
<body  style="width: 98%">
    <div class="header">
        <h1>添加定位地址</h1>
    </div>
    <form id="serviceForm" class="form-horizontal" method="post" >
        <input type="hidden" id="id" name="id" value="${entity.id}" />
        <div class="clearfix">
            <div class="form-group">
                <label for="locationName" class="control-label">定位地址：</label>
                <input type="text" id="locationName" name="locationName" class="form-control" value="${entity.locationName}">
            </div>
            <div class="form-group">
                <label for="firstLetter" class="control-label">首字母：</label>
                <input type="text" id="firstLetter" name="firstLetter" class="form-control" value="${entity.firstLetter}">
            </div>
            <div class="form-group">
                <label for="checkName" class="control-label">检验所名字：</label>
                <input type="text" id="checkName" name="checkName" class="form-control" value="${entity.checkName}">
            </div>
            <div class="form-group">
                <label for="serviceUrl" class="control-label">服务器地址：</label>
                <input type="text" id="serviceUrl" name="serviceUrl" class="form-control" value="${entity.serviceUrl}">
            </div>
            <div class="form-group">
                <label for="partition" class="control-label">分区号：</label>
                <input type="text" id="partition" name="partition" class="form-control" value="${entity.partition}">
            </div>
        </div>
        <div class="form-group submitBtn">

            <button type="button" class="store" data-dismiss="modal" id="closeModalButt" onclick="closeFrame()">关闭</button>
            <button type="submit" name="submit" class="store">保存</button>

        </div>
    </form>
    <script>
        $(document).ready(function() {
            var url = location.search;
            if( url.indexOf("&") != -1){
                $('.header h1').text('修改定位地址')
            }else{
                $('.header h1').text('添加定位地址')
            }
            $('#serviceForm').bootstrapValidator({
                message: 'This value is not valid',
                feedbackIcons: {
                    valid: 'glyphicon glyphicon-ok',
                    invalid: 'glyphicon glyphicon-remove',
                    validating: 'glyphicon glyphicon-refresh'
                },
                fields: {
                    locationName: {
                        validators: {
                            notEmpty: true
                        }
                    },
                    firstLetter:{
                        validators: {
                            notEmpty: true
                        }
                    },
                    checkName: {
                        validators: {
                            notEmpty: true
                        }
                    },
                    serviceUrl: {
                        validators: {
                            notEmpty: true
                        }
                    },
                    partition: {
                        validators: {
                            numeric: true
                        }
                    }
                }
            }).on('success.form.bv', function (e) {


                e.preventDefault();
                var _url = "";
                if ($("#id").val() == null || $("#id").val() == '') {
                    _url = '${URL_SERVICE_SAVE}';
                } else {
                    _url = '${URL_SERVICE_UPDATE}';
                }
                $.ajax({
                    url:_url,
                    type:'post',

                    data:$('#serviceForm').serialize(),
                    async : false, //默认为true 异步
                    error:function(res){
                        alert('error');
                        console.log('error'+res);
                    },
                    success:function(data){
                        console.log(data);
                        closeFrame();
                    }
                });
            });
        });
        //关闭并刷新
        function closeFrame(){

            // console.log(document.getElementById('testIframe'));

            // document.getElementById('testIframe').contentWindow.refreshTable();//ajax刷新子页面中DataTable表格数据

            window.parent.closeModal("update");

        }


    </script>
</body>
</html>
